package cn.tjnext.apply.dao;

import cn.tjnext.apply.entity.AbstractEntity;
import cn.tjnext.apply.entity.AdminEntity;
import cn.tjnext.apply.entity.UserEntity;
import cn.tjnext.apply.repositories.AdminRepository;
import cn.tjnext.apply.repositories.UserRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Created by cp on 2017/7/31.
 */
@Component
public class AdminDao extends AbstractEntityDao<AdminEntity, AdminRepository> {

    @Autowired
    private AdminRepository adminRepository;

    @Override
    protected AdminRepository getRepository() {
        return adminRepository;
    }

    @Override
    public Sort getDefaultSorting() {
        return AdminEntity.DEFAULT_SORTING;
    }

    @Override
    public Page<AdminEntity> searchByKeyword(String keyWord, Pageable pageable) {
        return getRepository().findByAccountLike(keyWord, pageable);
    }

    public AdminEntity findByAccount(String account) {
        return getRepository().findByAccount(account);
    }
}
